package com.xiangdao.dao;

import com.xiangdao.model.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.Map;

@Mapper
public interface UserDao {
    String TABLE_NAME = "user";
    String INSERT_FIELDS = "name,password,phoneId";
    String SELECT_FIELDS = "id,name,password,phoneId";

    /**
     * 注册一个用户
     * @param user
     * @return int
     */

    int addUser(User user);
    Integer updateUser(@Param("name") String name,@Param("email") String email,@Param("birthday") String birthday
    ,@Param("sex") String sex,@Param("city") String city,@Param("signature") String signature,@Param("school") String school
            ,@Param("enrollmentTime") String enrollmentTime,@Param("introduction") String introduction,@Param("qq") String qq
            ,@Param("studentid") String studentid,@Param("image") String image);
    /**
     * 根据用户名获得相应用户对象
     * @param name
     * @return User
     */
    User getUserByUsername(@Param("name") String name);

    /**
     * 根据用户id获得相应用户对象
     * @param id
     * @return User
     */
    User getUserById(@Param("id") Integer id);

    /**
     * 根据用户名获得id
     * @param name
     * @return
     */
    Integer getIdByUsername(@Param("name") String name);

    /**
     * 根据id获得用户名
     * @param id
     * @return
     */
    User getUsernameById(@Param("id") Integer id);

    String getPasswordByName(@Param("name") String password);

}
